using System.Collections.Generic;
using System.Globalization;
using EasyLibrary.AR.Classes;

namespace EasyLibrary.AR.Services
{
    public class JsonEncoder
    {
        private readonly Gps _coord;
     

        public JsonEncoder(Gps coord)
        {
            _coord = coord;
      
        }

        public override string ToString()
        {
            if (_coord == null) return null;

            //_coord.Latitude += new Random().NextDouble() * 2;
            //_coord.Course = (float)(360 * new Random().NextDouble());

            //Latitude,Longitude,TipoVeiculo,Matricula,RefIDTipoViatura
            var sb = new List<string>
                                  {
                                      "id: " + _coord.IdViatura,
                                      "matricula: '" + _coord.Matricula + "'",
                                      "tipoViatura: '"+_coord.RefIdTipoViatura+"'",
                                      "latitude: " + _coord.Latitude.ToString(CultureInfo.InvariantCulture),
                                      "longitude: " + _coord.Longitude.ToString(CultureInfo.InvariantCulture),
                                     };
            return "{" + string.Join(",", sb.ToArray()) + "}";
        }
    }
}
